/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-04-24
 * Time: 17:00
 */

class QueueNode{
    public int val;
    public QueueNode next;

    public QueueNode(int val){
        this.val = val;
    }
}
public class MyListQueue {
    public QueueNode head;
    public QueueNode last;

    public void offer(int val){  //入队
        QueueNode node = new QueueNode(val);
        if (this.head == null){
            this.head = node;
            this.last = node;
        }
        last.next = node;
        this.last = node;
    }


    public void poll(){ // 出队
        if (this.head == null){
            System.out.println("队列为空！");
            return;
        }
        System.out.println(head.val);
        this.head = head.next;
    }

    public QueueNode peek(){ // 返回队首元素
        if (this.head == null){
            System.out.println("队列为空！");
            return null;
        }
        return this.head;

    }




}
